#include "../include/AoEBullet.h"
#include "../include/Global.h"

AoEBullet::AoEBullet():Bullet()
{
    colorR = 0.8;
    colorG = 0.0;
    colorB = 0.0;
    Pos = Position(0,0);
    width = 0.25;
    stepSize = 0.3;
    height = 0.25;
    depth = .25;
    range = 1;
    minionIndex=0;
    splashRadius = 2;
    bulletDamage = 30;
    delay = 4;

}

void AoEBullet :: hitEffect(std::vector<Minion> &min, int i)
{
    for(int j = 0; j < min.size(); j++)
    {
        if(getDistance(min[i].getPos().Xpos, min[j].getPos().Xpos, min[i].getPos().Ypos, min[j].getPos().Ypos) <= splashRadius)
        {
                min[j].changeHealth(min[j].getHealth() - bulletDamage);
        }
         if(min[j].getHealth()<= 0 && min.size() != 0)
            {
                min.erase(min.begin()+j);
                //Since min.erase will change the index of ever minion in the vector
                //after the one being erased, we need to update the index of those minions.
                for(int newIndex = i; newIndex < min.size(); newIndex++)
                {
                    min[newIndex].SetIndex(newIndex);
                }
            }


    }

            Pos = {0,0};
            Zpos = 2.4;
            Timer.start();

}


AoEBullet::~AoEBullet()
{
    //dtor
}

